package welsir.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import welsir.entity.dos.User;
import welsir.entity.dto.UserDTO;
import welsir.entity.vo.PageVO;
import welsir.entity.vo.UserVO;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {
    /**
     * 通过用户名获取会员
     *
     * @param username 用户名
     * @return 会员
//     */
//    @Select("SELECT * FROM mt_user WHERE user_name=#{username}")
//    User findByUsername(@Param("username") String username);
//
//    @Select("SELECT * FROM member WHERE email=#{email}")
//    User findByEmail(@Param("email") String email);
//
//    @Select("SELECT * FROM member WHERE id=#{id}")
//    User findById(@Param("id") String id);
//
////    /**
////     * 添加用户
////     *
////     */
////    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
////    @Insert("INSERT INTO member (create_time,update_time,username,password,email,birthday,face,sex,store_id)" +
////            "VALUES(#{m.createTime},#{m.updateTime},#{m.username},#{m.password},#{m.email},#{m.birthday},#{m.face},#{m.sex},#{m.storeId})")
////    void add(@Param("m") User user);
//
//    @Update("UPDATE member SET password=#{password} WHERE email=#{email}")
//    int updatePassword(@Param("email") String email, @Param("password") String password);
//
//    @Update("UPDATE member SET password=#{password} WHERE id=#{id}")
//    void modifyPass(@Param("id") String member_id, @Param("password") String encodeNewPassword);
//
//    @Select({"<script>" +
//            "   select * from member" +
//            "   <where>" +
//            "       disabled=#{m.disabled}" +
//            "       <if test=\"m.username!=null and m.username.length\">" +
//            "           and instr(username,#{m.username})" +
//            "       </if>" +
//            "       <if test=\"m.email!=null and m.email.length\">" +
//            "           and instr(email,#{m.email})" +
//            "       </if>" +
//            "   </where>" +
//            "   limit #{p.offset},#{p.pageSize}" +
//            "</script>"})
//    List<UserVO> getUserPage(@Param("m") UserVO userVO, @Param("p") PageVO page);
//
//    @Select({"<script>" +
//            "   select count(id) from member" +
//            "   <where>" +
//            "       <if test=\"m.username!=null and m.username.length\">" +
//            "           instr(username,#{m.username})" +
//            "       </if>" +
//            "       <if test=\"m.email!=null and m.email.length\">" +
//            "           instr(email,#{m.email})" +
//            "       </if>" +
//            "   </where>" +
//            "</script>"})
//    long getUserNum(@Param("m") UserVO userVO);
//
//    @Update({"<script>" +
//            "update member set " +
//            "<if test=\"m.face!=null and m.face.length>0\">" +
//            "   face=#{m.face}," +
//            "</if>" +
//            "<if test=\"m.password!=null\">" +
//            "   password=#{m.password}," +
//            "</if>" +
//            "<if test=\"m.sex!=null\">" +
//            "   sex=#{m.sex}," +
//            "</if>" +
//            "<if test=\"m.birthday!=null\">" +
//            "   birthday=#{m.birthday}" +
//            "</if>" +
//            "where username=#{m.username}" +
//            "</script>"})
//    int updateUserByUsername(@Param("m") UserDTO userDTO);

}
